home *** CD-ROM | disk | FTP | other *** search
/ Aminet 38 / Aminet 38 (2000)(Schatztruhe)[!][Aug 2000].iso / Aminet / dev / c / fftPPC.lha / fftPPC / READ.DOC < prev    next >
Encoding:
Text File  |  2000-05-31  |  5.5 KB  |  180 lines

  1.  
  2.  
  3.                  FFT Program for Turbo-C
  4.  
  5.                        By
  6.  
  7.                      Steve Sampson
  8.  
  9.  
  10.                Version 2.6, November 1988
  11.  
  12.  
  13.    The FFT program and test signal generators included in the archive, can be
  14. used to perform signal analysis in the frequency domain, using samples in the
  15. time domain.  Historically the applications have ranged from music to radar.
  16. I recently have been doing some research in the radar field using this FFT to
  17. perform relative velocity measurements.  This program can be further refined
  18. to meet your needs.
  19.  
  20.    I initially uploaded a fairly basic program, and through feedback have
  21. made some improvements.  It's pretty complete now as far as a start for making
  22. your own specific version.  Earlier Unix compatability has been removed in
  23. favor of IBM graphics adaptors.
  24.  
  25.    This program uses graphics to present a 256 filter window.  My current
  26. application required complex data and resulted in 256 complex points.  You may
  27. use this with real data which results in 128 significant points.  If you feed
  28. the FFT real data only (Imaginary data set to zero), then the output will be a
  29. mirror image, and you can ignore the left side.
  30.  
  31. Some papers I found on the subject of FFTs are included at the end.  There are
  32. several books devoted to the subject also.
  33.  
  34. For an example try:
  35.  
  36.     sine in
  37.     1000
  38.     3000
  39.  
  40. Which will sample the 1 Khz data every 333 microseconds (1 / 3 Khz).  Note: The
  41. sample frequency should be greater than 2 times the input frequency (Nyquist
  42. and all that...).
  43.  
  44. Then run fft like so:
  45.  
  46.     fft in
  47.  
  48. And you should see a graphics display which has filters 0 through 255 on the
  49. X axis, and power on the Y axis.  All DC power in the time samples will appear
  50. in filter 128.  The fundamental display frequency is shown in filter 129 and
  51. can be computed as follows:
  52.  
  53.     T  = Time Increment Between Samples
  54.     N  = Number Of Samples (256)
  55.     Tp = N * T
  56.  
  57.     Then F = 1 / Tp
  58.  
  59.     In the example above, the time increment between samples is
  60.     1 / 3000 or 333 microseconds.  N = 256, so Tp = 85 milliseconds
  61.     and 1 / .005333 is 11.7 Hz per filter.
  62.  
  63.     Therefore each filter is a multiple of 11.7 Hertz.
  64.  
  65.     Filter 126            -23.4 Hz
  66.     Filter 127            -11.7 Hz
  67.     Filter 128    DC         00.0 Hz
  68.     Filter 129    Fundamental     11.7 Hz
  69.     Filter 130    Second Harmonic  23.4 Hz
  70.  
  71. In this case you'll find the sampling interval didn't work very well for the
  72. input frequency.  The display shows the power spread out over several filters.
  73. This is a limitation of the Discrete Fourier Transform in representing a
  74. continuous signal.
  75.  
  76. A better sample rate for 1000 Hz would be 4000 Hz, in which case T = 250 ms,
  77. Tp = 64 milliseconds, and F = 15.625 Hz.  1000 / 15.625 = 64.  All of the
  78. power should then appear in filter 192 (128 + 64) in this example.
  79.  
  80. Run it and see using:
  81.  
  82.     sine in
  83.     1000
  84.     4000
  85.  
  86.     fft in
  87.  
  88. By using negative frequencies in 'sine' you can generate opening targets:
  89.  
  90.     sine in
  91.     -1000
  92.     3000
  93.  
  94.     fft in
  95.  
  96. You can see in these examples where weighting functions would be useful.  For
  97. instance using weighting you could greatly attenuate the sidebands.  Usually
  98. the main lobe becomes a little wider however.  The current version does not
  99. perform any weighting.
  100.  
  101. For generating pulses, a second program 'pulse' is provided.  It pre-loads
  102. imaginary data with zeros.   For example:
  103.  
  104.     pulse in
  105.     .000006
  106.     .0000008
  107.  
  108.     fft in
  109.  
  110. Simulates a radar with a 6 microsecond pulse and 800 nanosecond range gates,
  111. and produces the typical pulse spectrum display.
  112.  
  113.  
  114. How to run the FFT program
  115. --------------------------
  116.  
  117. The program auto-detects CGA, EGA, and VGA graphics adaptors.  The CGA version
  118. cursor line is hard to see though.  VGA is untested.
  119.  
  120. When the program is run, a ruler line is drawn with tick marks every 5 filters.
  121. Also "Computing FFT" is displayed at the top of the screen.  The program is now
  122. busy computing the FFT and will not do anything useful until finished.
  123.  
  124. When the FFT computation is complete, the power plot will be performed and a
  125. verticle cursor line will appear.  "Computing FFT" will be replaced with
  126. "Filter # 128".  The program is then ready for input of commands.
  127.  
  128. The commands are:
  129.  
  130.     ESC        Escapes back to MS-DOS
  131.     LEFT        Moves the cursor left
  132.     RIGHT        Moves the cursor right
  133.     CTRLLEFT    Moves the cursor 10 filters left
  134.     CTRLRIGHT    Moves the cursor 10 filters right
  135.     HOME        Moves the cursor to filter 0
  136.     END        Moves the cursor to filter 255
  137.     F1        Prints the display on an Epson/IBM Compatable printer
  138.  
  139. A bee-bop when F1 is pressed means the printer has a problem (paper, power...).
  140.  
  141.  
  142. How to compile the programs
  143. ---------------------------
  144.  
  145. I use a Hard Disk configured per the Borland Manuals.  If this is your settup
  146. also; do this:
  147.  
  148.     1.  Copy the archive contents into any directory.
  149.     2.  Run \TURBOC\MAKE
  150.     3.  Three programs are made: fft.exe, sine.exe, and pulse.exe.
  151.  
  152. If you have any other system specific changes, then consult the makefile and
  153. Borland manuals.  I can also be reached at the address below.
  154.  
  155.  
  156. FFT References
  157. --------------
  158.  
  159. 1.    Fast Fourier Transforms On Your Home Computer, William D. Stanley,
  160.     Steven J. Peterson, BYTE Magazine, December 1978.  Basic idea comes
  161.     from this program.
  162.  
  163. 2.    8052 Microcomputer simplifies FFT Design, Arnold Rosenberg,
  164.     Electronics, May 5, 1983.  Used a bit reverse table based on the
  165.     routine in this program.
  166.  
  167. 3.    A Fast Fourier Transform for the 8080, Robert D. Fusfeld,
  168.     Dr. Dobbs, Number 44.  Gave me some ideas.
  169.  
  170. 4.    A Guided Tour of the Fast Fourier Transform, G. D. Bergland,
  171.     IEEE Spectrum, July 1969.
  172.  
  173. 5.    FFT - Shortcut to Fourier Analysis, Richard Klahn, Richard R. Shively,
  174.     Electronics, April 15 1968.
  175.  
  176. ---
  177. All programs are entered into the Public Domain, No rights reserved.
  178. Steve Sampson, Box 45668, Tinker AFB, OK, 73145
  179. 75136,626
  180.